<template>
    <div class="maxContainer content">
        <div class="formContainer">
            <el-form :inline="true" :model="extensionDataParamPromotionRecord" >
                <el-checkbox-group>
                    <el-form-item label="关系选择">
                        <el-select placeholder="请选择" v-model="extensionDataParamPromotionRecord.query.selectType">
                            <el-option v-for="item in gxxlk" :key="item.id" :label="item.name" :value="item.id"></el-option>
                        </el-select>
                    </el-form-item>
                </el-checkbox-group>
                <el-checkbox-group>
                    <el-form-item label="用户ID">
                        <el-input v-model="extensionDataParamPromotionRecord.query.userId" placeholder="用户ID"></el-input>
                    </el-form-item>
                    <el-form-item label="用户邮箱">
                        <el-input v-model="extensionDataParamPromotionRecord.query.email" placeholder="用户邮箱"></el-input>
                    </el-form-item>
                    <el-form-item label="用户昵称">
                        <el-input v-model="extensionDataParamPromotionRecord.query.userName" placeholder="用户昵称"></el-input>
                    </el-form-item>
                    <el-form-item label="推广码">
                        <el-input v-model="extensionDataParamPromotionRecord.query.userCode" placeholder="推广码"></el-input>
                    </el-form-item>
                    <el-form-item>
                        <el-button @click="defaultSearch()">搜索</el-button>
                    </el-form-item>
                </el-checkbox-group>
            </el-form>
        </div>
        <div class="min tableData">
            <el-table :data="tableDataPromotionRecord" border style="width: 100%">
                <el-table-column prop="userId" label="用户ID" ></el-table-column>
                <el-table-column prop="email" label="用户邮箱" ></el-table-column>
                <el-table-column prop="userName" label="用户昵称" > </el-table-column>
                <el-table-column prop="userCode" label="推广码" > </el-table-column>
                <el-table-column prop="createdAt" label="时间" > </el-table-column>
            </el-table>
            <el-pagination
            background
            layout="prev, pager, next"
            :page-count="extensionDataParamPromotionRecord.pageCount"
            @current-change="currentPageChange">
        </el-pagination>
        </div>
    </div>
</template>

<script>
import api from '../../../api/Basicpath/index'
export default {
    data() {
      return {
        extensionDataParamPromotionRecord: {
            "currentPage":1,
            "pageSize":3,
            "total":0,
            "pageCount":0,
            "query":{
                "selectType":"1",
                "userId":"",
                "email":"",
                "userName":"",
                "userCode":""
            }
        },
        tableDataPromotionRecord: [],
      gxxlk: [{
          id: '1',
          name: '推广'
        }, {
          id: '2',
          name: '被推广'
        }],
      }
    },
    methods: {
        currentMonthLast(){
            var date=new Date();
            var currentMonth=date.getMonth();
            var nextMonth=++currentMonth;
            var nextMonthFirstDay=new Date(date.getFullYear(),nextMonth,1);
            var oneDay=1000*60*60*24;
            return new Date(nextMonthFirstDay-oneDay);
        },
        defaultSearch(){
            this.extensionDataParamPromotionRecord.currentPage = 1;
            this.extensionDataParamPromotionRecord.pageCount = 1;
            this.onSearch();
        },
        onSearch() {
            this.$axios.post(`${api}/gamemall/inviteRecord/searchListByQuery`,this.extensionDataParamPromotionRecord)
				.then( res => {
				if(res.code === 200){
                    console.log(res.data);
                    if(res.data==null){
                        this.extensionDataParamPromotionRecord.currentPage = 1;
                        this.extensionDataParamPromotionRecord.pageCount = 0;
                        this.tableDataPromotionRecord =[];
                    }else{
                        this.tableDataPromotionRecord = res.data.list;
					    this.extensionDataParamPromotionRecord.pageCount = res.data.pages;
                    }
				}else if(res.code === 500){
					// this.$message({
					// message: res.msg || '请求数据失败',
					// type: 'warning'
					// })
				}
				})
				.catch( err =>{
				// this.$message({
				// 	message: err.msg || '请求数据失败',
				// 	type: 'warning'
				// 	})
                }
            );
        },
        currentPageChange(currentPage) {
            this.extensionDataParamPromotionRecord.currentPage = currentPage;
            this.onSearch();
        }
    },
    created:function (){
        //this.extensionDataParamPromotionRecord.query.selectType = 1;
        this.onSearch();
    }
};
</script>
<style scoped>
    .content {
        width: 99%;
        height: 99%;
        display: flex;
        flex-direction: column;
        /* justify-content: center; */
        padding-top: 2%;
        margin-left: 0.5%;
        border: 1px solid #EBEEF5;
        background-color: #FFF;
        border-radius: 0.325rem;
        font-family: Avenir,Helvetica,Arial,sans-serif;
    }
    .el-form{
        text-align: left;
        margin-left: 2%;
    }
</style>